/*
 * This code is property of CoreObjects. Use, duplication and disclosure
 * in any form without permission of copyright holder is prohibited.
 *
 */

package com.nen.session;

/**
 *
 * @author amitm
 */
public final class SessionRequestHandler {
    private SessionRequestHandler() {
        
    }

    public static ServiceResponse process(ServiceRequest request) {
        ServiceResponse response =  new ServiceResponse();
        String sessionId = request.getSessionId();
        boolean activeSession = SessionMapHolder.isActiveSession(sessionId);
        System.out.println(">>>> activeSession = "+activeSession);
        
        response.addField("sessionId", sessionId);
        response.addField("active", String.valueOf(activeSession));

        if(activeSession && request.isFetchUserInfo()) {
            SessionMapItem item = SessionMapHolder.getEntry(sessionId);
            response.addFields(item.getUserInfoMap());
        }

        return response;
    }

}
